package com.punai.standard.controller;

import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.domain.TreeBo;
import com.punai.standard.domain.constants.StaConstants;
import com.punai.standard.service.IStaJxChapterService;
import com.punai.standard.service.IStaVersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 机械章节Controller
 * 
 * @author zhx
 * @date 2022-12-21
 */
@RestController
@RequestMapping("/sta/jxChapter")
public class StaJxChapterController extends BaseController
{
    @Autowired
    private IStaJxChapterService staJxChapterService;
    @Autowired
    private IStaVersionService staVersionService;

    @PreAuthorize("@ss.hasPermi('sta:jxChapter:list')")
    @GetMapping("/treeData/{versionsId}")
    public AjaxResult treeData(@PathVariable("versionsId") String versionsId)
    {
        List<TreeBo> treeData = staJxChapterService.treeData(versionsId);
        return AjaxResult.success(treeData);
    }

    @PreAuthorize("@ss.hasPermi('sta:jxChapter:list')")
    @GetMapping("/getVersionList")
    public AjaxResult getVersionList()
    {
        return AjaxResult.success(staVersionService.getVersionList(StaConstants.JX_TYPE, getCompanyId()));
    }
}
